#ifndef ZIGBUSMESSAGE_H
#define ZIGBUSMESSAGE_H

#include <QString>
#include <QList>
/*
#include "ZigbusItem.h"
#include "ZigbusModuleId.h"
#include "ZigbusNetworkId.h"
#include "ZigbusOrder.h"
#include "ZigbusAddressNeed.h"
#include "ZigbusType.h"
#include "ZigbusNumericIniState.h"
#include "ZigbusIO.h"
#include "ZigbusMeteoType.h"
#include "ZigbusAddressingType.h"
#include "ZigbusTimeItem.h"
#include "ZigbusServoPosition.h"
#include "ZigbusPwmValue.h"
#include "ZigbusOrderDirection.h"
#include "ZigbusTemperatureItem.h"
#include "ZigbusHygroItem.h"
#include "ZigbusTieActivItem.h"
#include "ZigbusTieRevertItem.h"
#include "ZigbusAnalogicReference.h"
#include "ZigbusIsAnalogicItem.h"
*/

#include <ZigbusItemFactory.h>
#include <QMetaType>
/*
 network id = 2 hexa digits
 module id = 4 hexa digits
 */
class ZigbusMessage
{
private:
    ZigbusNetworkId networkId;
    ZigbusModuleId moduleId;
    ZigbusOrder order;
    QList<ZigbusItem*> itemList;

public:
    ZigbusMessage();
    ZigbusMessage(const ZigbusNetworkId& networkId, const ZigbusModuleId& moduleId,
                  const ZigbusOrder& order);
    ZigbusMessage(const QString& str);
    ZigbusMessage(const ZigbusMessage& other);
    static ZigbusMessage createMessage(const QString& trame, bool *ok = NULL);
    ~ZigbusMessage();
    ZigbusMessage& operator=(const ZigbusMessage& other);
    bool equals(const ZigbusMessage& other) const;
    QString trame() const;
    QString toString() const;
    int toInt() const;
    bool isValid() const;
    const ZigbusModuleId& getModuleId() const { return moduleId; }
    void setModuleId(const ZigbusModuleId& id) { moduleId = id; }
    const ZigbusNetworkId& getNetworkId() const { return networkId; }
    void setNetworkId(const ZigbusNetworkId& id) { networkId = id; }
    const ZigbusOrder& getOrder() const { return order; }
    void setOrder(const ZigbusOrder& order) { this->order = order; }
    const QList<ZigbusItem*>& items() const { return itemList; }
    QList<ZigbusItem*>& items() { return itemList; }
    void setItemList(const QList<ZigbusItem*>& list) { itemList = list; }
    const ZigbusItem& itemAt(int i) const;
    ZigbusItem *itemPtrAt(int i) const;
    void clearArgList();
    void addOrder(const ZigbusOrder& order);
    void addAddrNeeded(const ZigbusAddressNeed& need);
    void addType(const ZigbusType& type);
    void addNumericIniState(const ZigbusNumericIniState& iniState);
    void addIO(const ZigbusIO& io);
    void addMeteoType(const ZigbusMeteoType& meteoType);
    void addAddressingType(const ZigbusAddressingType& type);
    void addTimeItem(const ZigbusTimeItem& time);
    void addServoPosition(const ZigbusServoPosition& position);
    void addPwmValue(const ZigbusPwmValue& value);
    void addOrderDirection(const ZigbusOrderDirection& direction);
    void addTemperature(const ZigbusTemperatureItem& temp);
    void addHygro(const ZigbusHygroItem& hygro);
    void addTieActiv(const ZigbusTieActivItem& activ);
    void addTieRevert(const ZigbusTieRevertItem& revert);
    void addIsAnalogItem(const ZigbusIsAnalogicItem& isAnalog);
    void addAnalogicRef(const ZigbusAnalogicReference& ref);
    QString fullAddress() const;
};

bool operator==(const ZigbusMessage& a, const ZigbusMessage& b);

Q_DECLARE_METATYPE(ZigbusMessage)

#endif // ZIGBUSMESSAGE_H
